package org.itcast.travel.exception;

import org.itcast.travel.pojo.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author WangCong
 * 全局异常处理器
 * 2024/12/20 17:42
 */
@RestControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler({UpdPwdExcepton.class, LoginErrException.class, LikeNotAllowException.class})
    public Result handleException2(Exception e) {
//        e.printStackTrace();
        return Result.error(e.getMessage());
    }

/*    @ExceptionHandler(LikeNotAllowException.class)
    public Result handleException(Exception e) {
        e.printStackTrace();
        return Result.error(e.getMessage());
    }*/

/*    @ExceptionHandler(LoginErrException.class)
    public Result handleException1(Exception e) {
//        e.printStackTrace();
        return Result.error(e.getMessage());
    }*/

    @ExceptionHandler
    public Result handleOtherException(Exception e) {
        e.printStackTrace();
        return Result.error("出错了!");
    }
    @ExceptionHandler(VoteNotAllowedExcepton.class)
    public Result handleException3(Exception e) {
//        e.printStackTrace();
        return Result.error(e.getMessage());
    }
}
